package administrador;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
public class MacAddress {
    public String mac(){
          String macc="";
            try {		
                InetAddress address = InetAddress.getLocalHost();
                NetworkInterface ni = NetworkInterface.getByInetAddress(address);
                byte[] mac = ni.getHardwareAddress();
                for (int i = 0; i < mac.length; i++) {			
                    macc+=String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "");
                }
                return macc;
            } catch (UnknownHostException e) {
                e.printStackTrace();	
            } catch (SocketException e) {
                e.printStackTrace();
            }
        return macc;
    }
} 